package com.healthbox.resultsservice.controller;

import com.healthbox.resultsservice.entity.CommonResult;
import com.healthbox.resultsservice.service.TOadminNoticesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RequestMapping("/TOadmin/notice")
@RestController
@Api(tags="检测机构管理员公告服务")
public class TOadminNoticesController {

    @Resource
    TOadminNoticesService toadminNoticesService;

    /* 检测机构管理员增加公告 */
    @PostMapping(value = "/create")
    @ApiOperation(value="检测机构管理员增加公告")
    public CommonResult create(
            @RequestBody Map<String,Object> map,
            @RequestHeader(value = "user-phone") String userPhone,
            @RequestHeader(value = "user-role") String userRole
        ){
        return toadminNoticesService.create(map, userPhone, userRole);
    }

    /* 检测机构管理员删除公告 */
    @PostMapping(value = "/delete")
    @ApiOperation(value="检测机构管理员删除公告")
    public CommonResult delete(
            @RequestBody Map<String,Object> map,
            @RequestHeader(value = "user-phone") String userPhone,
            @RequestHeader(value = "user-role") String userRole
        ){
        return toadminNoticesService.delete(map, userPhone, userRole);
    }

    /* 检测机构管理员修改公告 */
    @PostMapping(value = "/update")
    @ApiOperation(value="检测机构管理员修改公告")
    public CommonResult update(
            @RequestBody Map<String,Object> map,
            @RequestHeader(value = "user-phone") String userPhone,
            @RequestHeader(value = "user-role") String userRole
        ){
        return toadminNoticesService.update(map, userPhone, userRole);
    }

    /* 检测机构管理员查看公告 */
    @GetMapping(value = "/retrieve")
    @ApiOperation(value="检测机构管理员查看公告")
    public CommonResult retrieve(
            @RequestHeader(value = "user-phone") String userPhone,
            @RequestHeader(value = "user-role") String userRole
        ){
        return toadminNoticesService.retrieve(userPhone, userRole);
    }
}
